﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<DeklaritModel.InvoiceDataSet>" %>


<%@ Import Namespace="System.Data" %>


<table width="100%" class="formPageBody" >
	<tr>
		<td colspan="2">
			<%= Html.ValidationSummary() %>
		</td>
	</tr> 
   <tr>
		<td>
			<%= Html.Hidden("InvoiceId", Model == null || Model.Invoice.Rows.Count == 0 ? (object)null : Model.Invoice[0].InvoiceId) %>
			<%= Html.Hidden("MenuAction") %>
			<%= Html.Hidden("Mode") %>
			<%= Html.Hidden("InstantiatedAttributes") %>
			<%= Html.Hidden("RowIndex") %>
			<%	int? editableIndex = null;	%>
            <%= Html.Hidden("OptionAddedToCombo") %>
			<%  bool? prompt = (bool?)ViewData["Prompt"];   %>
            <%= Html.Hidden("Prompt", prompt) %>
            <%  if (prompt ?? false){
                    string promptAttribute = (string)ViewData["PromptAttribute"];
                    bool? promptReturn = (bool?)ViewData["PromptReturn"];    %>
                <%= Html.Hidden("PromptAttribute", promptAttribute) %>
                <%= Html.Hidden("Prompt_" + promptAttribute, Model == null || Model.Invoice.Rows.Count == 0 ? (object)null : Model.Invoice[0][promptAttribute]) %>
			    <%= Html.Hidden("PromptReturn", promptReturn.HasValue && promptReturn.Value ? "true" : "false")%>
            <%  } %>

	<table cellspacing="1" cellpadding="1" border="0">
		<tr>
			
     
     										<td class="nowrapClass smallWidth"     >
     											<label id="lblInvoiceDescription1" class="formLabelDescription "  ><%=  Resources.StringResources.InvoiceInvoiceDescriptionDescription %></label>
     										</td>
				
			
     
     										<td class="nowrapClass"   >
     											<table cellspacing="1" cellpadding="0" border="0"  >
     												<tr>
     													<td class="nowrapClass" >
     														<%= Html.TextBox("InvoiceDescription", Model == null || Model.Invoice.Rows.Count == 0 ? (object)null : Model.Invoice[0].InvoiceDescription, "formText", "20", "20", ((EnumMode)ViewData["Mode"]) != EnumMode.Insert && ((EnumMode)ViewData["Mode"]) != EnumMode.Update || ViewData["ReadOnly_InvoiceDescription"] != null, "formTextView", false, "", false) %>
     													</td>
     												</tr>
     											</table>
     										</td>
     									
     
				
			<td>
			</td>
		</tr>
		<tr>
			
     
     										<td class="nowrapClass smallWidth"     >
     											<label id="lblClienteId1" class="formLabelDescription "  ><%=  Resources.StringResources.InvoiceClienteIdDescription %></label>
     										</td>
				
			
     
     										<td class="nowrapClass"   >
     											<table cellspacing="1" cellpadding="0" border="0"  >
     												<tr>
     													<td class="nowrapClass" >
     														<%= Html.TextBox("ClienteId", Model == null || Model.Invoice.Rows.Count == 0 ? (object)null : Model.Invoice[0].ClienteId, "formTextNumeric", "5", "5", ((EnumMode)ViewData["Mode"]) != EnumMode.Insert && ((EnumMode)ViewData["Mode"]) != EnumMode.Update || ViewData["ReadOnly_ClienteId"] != null, "formTextView", false, "", false) %>
     													</td>
     													<td valign="baseline" class="nowrapClass" >
     													<!--
     														<* Html.Hidden("txtPromptClienteId") *>
     														
     														<dkweb:DeklaritTextBox runatt="server" id="txtPromptClienteId" ReadOnly="True" CssClass="formText"  Width="0em" Columns="0"  >
     														</dkweb:DeklaritTextBox>
     														-->
     													</td>
     													<td valign="bottom" class="nowrapClass" >
     														<%	if(!(((EnumMode)ViewData["Mode"]) != EnumMode.Insert && ((EnumMode)ViewData["Mode"]) != EnumMode.Update || ViewData["ReadOnly_ClienteId"] != null))
     															{	%>
     														<img id="promptClienteId" onclick="ClienteClienteId( this, null );return false;" src="<%= (string)Session["ThemePath"] %>Images/prompt.gif" style="cursor:pointer" />
     														<%	}	%>
     													</td>
     													<td class="nowrapClass" >
     													<!--
     														validador de numero correcto
     														<asp:CompareValidator runatt="server" CssClass="formValidatorLabel" id="ValidateDkTextClienteId" ControlToValidate="txtClienteId" Operator="DataTypeCheck" Type="Integer" ErrorMessage="<IMG src='~/Images/error.gif' border='0' align='absmiddle' alt='Please enter a valid number'>"></asp:CompareValidator>
     														-->
     													</td>
     													<td class="nowrapClass" >
     														<%= Html.ValidationMessage("ClienteId", "*", "formValidatorLabel") %>
     														<!--
     														<asp:RequiredFieldValidator runatt="server" CssClass="formValidatorLabel" id="ValidateRequiredDkNumberClienteId" ControlToValidate="txtClienteId" ErrorMessage="<IMG src='~/Images/error.gif' border='0' align='absmiddle' alt='Please enter a valid number'>"></asp:RequiredFieldValidator>
     														-->
     													</td>
     												</tr>
     											</table>
     										</td>
     									
     
				
			<td>
			</td>
		</tr>
		<tr>
			
     
     										<td class="nowrapClass smallWidth"     >
     											<label id="lblClienteName1" class="formLabelDescription "  ><%=  Resources.StringResources.InvoiceClienteNameDescription %></label>
     										</td>
				
			
     
     										<td class="nowrapClass"   >
     											<span id="lblClienteName" class="formLabel" ><%= Model == null || Model.Invoice.Rows.Count == 0 || Model.Invoice[0].IsClienteNameNull() ? "" : Html.Encode(Model.Invoice[0].ClienteName)%></span>
     											<input type="hidden" name="hiddenlblClienteName" >
     										</td>
     									
     
				
			<td>
			</td>
		</tr>
		<tr>
			
     
     										<td class="nowrapClass smallWidth"     >
     											<label id="lblInvoiceLineLastIndex1" class="formLabelDescription "  ><%=  Resources.StringResources.InvoiceInvoiceLineLastIndexDescription %></label>
     										</td>
				
			
     
     										<td class="nowrapClass"   >
     											<table cellspacing="1" cellpadding="0" border="0"  >
     												<tr>
     													<td class="nowrapClass" >
     														<%= Html.TextBox("InvoiceLineLastIndex", Model == null || Model.Invoice.Rows.Count == 0 ? (object)null : Model.Invoice[0].InvoiceLineLastIndex, "formTextNumeric", "5", "5", ((EnumMode)ViewData["Mode"]) != EnumMode.Insert && ((EnumMode)ViewData["Mode"]) != EnumMode.Update || ViewData["ReadOnly_InvoiceLineLastIndex"] != null, "formTextView", false, "", false) %>
     													</td>
     													<td class="nowrapClass" >
     													<!--
     														validador de numero correcto
     														<asp:CompareValidator runatt="server" CssClass="formValidatorLabel" id="ValidateDkTextInvoiceLineLastIndex" ControlToValidate="txtInvoiceLineLastIndex" Operator="DataTypeCheck" Type="Integer" ErrorMessage="<IMG src='~/Images/error.gif' border='0' align='absmiddle' alt='Please enter a valid number'>"></asp:CompareValidator>
     														-->
     													</td>
     													<td class="nowrapClass" >
     														<%= Html.ValidationMessage("InvoiceLineLastIndex", "*", "formValidatorLabel") %>
     														<!--
     														<asp:RequiredFieldValidator runatt="server" CssClass="formValidatorLabel" id="ValidateRequiredDkNumberInvoiceLineLastIndex" ControlToValidate="txtInvoiceLineLastIndex" ErrorMessage="<IMG src='~/Images/error.gif' border='0' align='absmiddle' alt='Please enter a valid number'>"></asp:RequiredFieldValidator>
     														-->
     													</td>
     												</tr>
     											</table>
     										</td>
     									
     
				
			<td>
			</td>
		</tr>
		<tr>
			

										<td  colspan="2"   >
											<%= Html.Hidden("InvoiceLineAddingLine", ViewData["InvoiceLineAddingLine"])%>
											<table cellspacing="1" cellpadding="1" border="0">
												<tr>
													<td>
														<span class="formLabelDescription">InvoiceLine</span>
													</td>
												</tr>
												<tr>
													<td>
                                                        <table class="data-table" cellpadding="0" cellspacing="0">
                                                            <thead>
                                                                <tr>
                                                                    <th>
                                                                        <%=  Resources.StringResources.InvoiceInvoiceLineIdDescription %>
                                                                    </th>
                                                                    <th>
                                                                        <%=  Resources.StringResources.InvoiceProductIdDescription %>
                                                                    </th>
                                                                    <th>
                                                                        <%=  Resources.StringResources.InvoiceProductNameDescription %>
                                                                    </th>
                                                                    <th>
                                                                        <%=  Resources.StringResources.InvoiceInvoiceLineProductValueDescription %>
                                                                    </th>
                                                                    <th>
                                                                        <%=  Resources.StringResources.InvoiceInvoiceLineProductQuantityDescription %>
                                                                    </th>
                                                                    <th>
                                                                    </th>
                                                                    <th>
                                                                    </th>
                                                                </tr>
                                                            </thead>
                                                            <tbody>
                                                                <%
                                                                    editableIndex = null;
                                                                    bool InvoiceLineAddingLine = ViewData["InvoiceLineAddingLine"] != null && ((bool)ViewData["InvoiceLineAddingLine"]);
                                                                    if ((Model == null || Model.InvoiceLine.Rows.Count == 0) && !InvoiceLineAddingLine)
                                                                    {   %>
                                                                 <tr>
                                                                    <td>
                                                                    </td>
                                                                    <td>
                                                                    </td>
                                                                    <td>
                                                                    </td>
                                                                    <td>
                                                                    </td>
                                                                    <td>
                                                                    </td>
                                                                    <td>
                                                                    </td>
                                                                    <td>
                                                                    </td>
                                                                </tr>
                                                                <%
                                                                    }
                                                                    else
                                                                    {
                                                                        editableIndex = ViewData["InvoiceLineEditableIndex"] != null ? (int?)ViewData["InvoiceLineEditableIndex"] : null;
                                                                        int total = Model.InvoiceLine.Count;                                                                        
                                                                        if(InvoiceLineAddingLine)
                                                                        {
                                                                            total++;
                                                                        }
                                                                        for(int i = 0; i < total; i++)
                                                                        {
																			DeklaritModel.InvoiceDataSet.InvoiceLineRow row = null;
                                                                            if(i < Model.InvoiceLine.Count)
                                                                            {
                                                                                row = Model.InvoiceLine[i];
                                                                            }
                                                                            if (row == null || row.RowState != DataRowState.Deleted)
                                                                            {
																				if (i == editableIndex)
																				{	%>
                                                                 <tr>
     															<td align="right">
     																<!-- if ( att.DataType==DeklaritType.Double || att.DataType==DeklaritType.Decimal ) { -> DataFormatString="{0:n0}" -->
     																<%= Html.TextBox("InvoiceLineId", row == null ? Model.InvoiceLine.InvoiceLineIdColumn.DefaultValue : row.InvoiceLineId, "formTextNumeric", "5", "5", row != null && row.RowState != DataRowState.Added, "formTextView", false, "", false) %>
     															</td>
     															<td class="nowrapClass">
     																<table cellspacing="0" cellpadding="0" border="0">
     																	<tr>
     																		<td class="nowrapClass" style="padding:0;border-style:none;" >
     																			<%= Html.TextBox("ProductId", row == null ? Model.InvoiceLine.ProductIdColumn.DefaultValue : row.ProductId, "formTextNumeric", "4", "5", false, "formTextView", false, "", false) %>
     																		</td>
     																		<td valign="bottom" class="nowrapClass" style="padding:0;border-style:none;" >
     																			<img id="promptProductId" onclick="ProductProductId( this, new Array( 'ProductId' ) );return false;" src="<%= (string)Session["ThemePath"] %>Images/prompt.gif" style="cursor:pointer;" />
     																		</td>
     																		<td class="nowrapClass" style="padding:0;border-style:none;" >
     																			<!--<asp:CompareValidator runatt="server" CssClass="formValidatorLabel" id="ValidateDkTextProductId" ControlToValidate="txtProductId" Operator="DataTypeCheck" Type="Integer" ErrorMessage="<IMG src='App_Themes/Default/Images/error.gif' border='0' align='absmiddle' alt='Please enter a valid number'>"></aspCompareValidator>
     																			-->
     																		</td>
     																		<td class="nowrapClass" style="padding:0;border-style:none;" >
     																			<!--
     																			<asp:RequiredFieldValidator runatt="server" CssClass="formValidatorLabel" id="ValidateRequiredDkNumberProductId" ControlToValidate="txtProductId" ErrorMessage="<IMG src='App_Themes/Default/Images/error.gif' border='0' align='absmiddle' alt='Please enter a valid number'>"></asp:RequiredFieldValidator>
     																			-->
     																		</td>
     																	</tr>
     																</table>
     															</td>
                                                                     <td class="nowrapClass">
                                                                     	<%= row == null || row.IsProductNameNull() ? (object)null : Html.Encode(row.ProductName)%>
                                                                     </td>
     															<td align="right">
     																<!-- if ( att.DataType==DeklaritType.Double || att.DataType==DeklaritType.Decimal ) { -> DataFormatString="{0:n2}" -->
     																<%= Html.TextBox("InvoiceLineProductValue", row == null ? Model.InvoiceLine.InvoiceLineProductValueColumn.DefaultValue : row.InvoiceLineProductValue, "formTextNumeric", "10", "11", false, "formTextView", false, "", false) %>
     															</td>
     															<td align="right">
     																<!-- if ( att.DataType==DeklaritType.Double || att.DataType==DeklaritType.Decimal ) { -> DataFormatString="{0:n0}" -->
     																<%= Html.TextBox("InvoiceLineProductQuantity", row == null ? Model.InvoiceLine.InvoiceLineProductQuantityColumn.DefaultValue : row.InvoiceLineProductQuantity, "formTextNumeric", "5", "5", false, "formTextView", false, "", false) %>
     															</td>
                                                                    <td style="padding:0">
                                                                        <a onclick="lineAction('InvoiceLine_ConfirmLine', <%= i %>)">
                                                                            <img alt="<%= Deklarit.Resources.Resources.captionConfirmweb %>" title="<%= Deklarit.Resources.Resources.captionConfirmweb %>" src="<%= (string)Session["ThemePath"] %>Images/Confirm.gif" style="cursor:pointer" /></a>
                                                                    </td>
                                                                    <td style="padding:0">
                                                                        <a onclick="lineAction('InvoiceLine_CancelLine', <%= i %>)">
                                                                            <img alt="<%= Deklarit.Resources.Resources.captionCancelweb %>" title="<%= Deklarit.Resources.Resources.captionCancelweb %>" src="<%= (string)Session["ThemePath"] %>Images/Cancel.gif" style="cursor:pointer" /></a>
                                                                    </td>
                                                                </tr>
                                                                <%
																				}
																				else
																				{	%>
                                                                <tr>
                                                                     <td align="right">
                                                                     	<%= Html.Encode(row.InvoiceLineId)%>
                                                                     </td>
                                                                     <td align="right">
                                                                     	<%= Html.Encode(row.ProductId)%>
                                                                     </td>
                                                                     <td class="nowrapClass">
                                                                     	<%= row.IsProductNameNull() ? (object)null : Html.Encode(row.ProductName)%>
                                                                     </td>
                                                                     <td align="right">
                                                                     	<%= Html.Encode(row.InvoiceLineProductValue)%>
                                                                     </td>
                                                                     <td align="right">
                                                                     	<%= Html.Encode(row.InvoiceLineProductQuantity)%>
                                                                     </td>
                                                                    <td style="padding:0">
                                                                        <%	if (!(((EnumMode)ViewData["Mode"]) != EnumMode.Insert && ((EnumMode)ViewData["Mode"]) != EnumMode.Update))
																			{	%>
                                                                        <a onclick="lineAction('InvoiceLine_EditLine', <%= i %>)">
																			<img alt="<%= Deklarit.Resources.Resources.captionUpdateweb %>" title="<%= Deklarit.Resources.Resources.captionUpdateweb %>" src="<%= (string)Session["ThemePath"] %>Images/Edit.png" style="cursor:pointer" />
                                                                        <%	}	%>
                                                                    </td>
                                                                    <td style="padding:0">
                                                                        <% if (!editableIndex.HasValue && !(((EnumMode)ViewData["Mode"]) != EnumMode.Insert && ((EnumMode)ViewData["Mode"]) != EnumMode.Update))
                                                                           { %>
                                                                        <a onclick="lineAction('InvoiceLine_DeleteLine', <%= i %>)">
																			<img alt="<%= Deklarit.Resources.Resources.captionDeleteweb %>" title="<%= Deklarit.Resources.Resources.captionDeleteweb %>" src="<%= (string)Session["ThemePath"] %>Images/Delete.png" style="cursor:pointer" />
                                                                        <% } %>
                                                                    </td>
                                                                </tr>
                                                                <%
																				}
																			}
                                                                        }
                                                                    }	%>
                                                            </tbody>
                                                        </table>
													</td>
												</tr>
												<tr>
													<td>
                                                        <%	if (!editableIndex.HasValue && !(((EnumMode)ViewData["Mode"]) != EnumMode.Insert && ((EnumMode)ViewData["Mode"]) != EnumMode.Update))
                                                            {	%>
															<a title="<%= Deklarit.Resources.Resources.AddLine %>" href="javascript:submitForm('InvoiceLine_AddLine', true)">
																<img style="border-style: none;" title="<%= Deklarit.Resources.Resources.AddLine %>" alt="<%= Deklarit.Resources.Resources.AddLine %>" src="<%= (string)Session["ThemePath"] %>Images/new.gif" /></a>
															<a class="HyperLinkNewText" href="javascript:submitForm('InvoiceLine_AddLine', true)"><%= Deklarit.Resources.Resources.AddLine %></a>
                                                        <%	}	%>
													    <!--<dkweb:DeklaritImageButton ID="btnAddgrdInvoiceLine" SkinID="DeklaritImageButton" runatt="server" CausesValidation="False"  Text="Add Line" Enabled="<-# IsLastPage( grdInvoiceLine ) ->" OnClick="NewLine" ></dkweb:DeklaritImageButton-->
                            						</td>
												</tr>
											</table>
										</td>
				
				
			<td>
			</td>
		</tr>
	</table>
		</td>
	</tr>
	<tr class="formFooter">
		<td colspan="4">
	
			<table cellspacing="2" cellpadding="2" border="0">
				<tr>
					<td valign="bottom" colspan="1">
						<img src="<%= (string)Session["ThemePath"] %>Images/LeftBottom.gif" />
					</td>
					<td>
				<!--		<dkweb:DeklaritImageButton ID="btnConfirm" SkinID="DeklaritImageButton" runatt="server" CausesValidation="True"  Text="Confirm"  ></dkweb:DeklaritImageButton>	-->
					</td>
					<td >
				<!--		<dkweb:DeklaritImageButton ID="btnCancel" SkinID="DeklaritImageButton" runatt="server" CausesValidation="False"  Text="Cancel"  ></dkweb:DeklaritImageButton>	-->
					</td>
					<td valign="bottom" align="right" colspan="1">
						<img src="<%= (string)Session["ThemePath"] %>Images/RightBottom.gif" />
					</td>
				</tr>
			</table>
		</td>
	</tr>
</table>
